import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-05-08
 * Time: 11:33
 */
public class udp_dict_Server extends udp_server{
    private HashMap<String,String> dict=new HashMap<>();

    public udp_dict_Server(int port) throws SocketException {
        super(port);
        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("fuck", "卧槽");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "该词没有查询到!");
    }

    public static void main(String[] args) throws IOException {
        udp_dict_Server server = new udp_dict_Server(9090);
        // start 不需要重新再写一遍了. 直接就复用了之前的 start !
        server.start();
    }
}
